<?php declare(strict_types=1);


namespace App\Http\Controller;

use App\Rpc\Lib\MessageInterface;
use Exception;
use Swoft\Http\Server\Annotation\Mapping\Controller;
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
use Six\Rpc\Client\Annotation\Mapping\Reference;

/**
 * Class RpcController
 *
 * @since 2.0
 * @Controller(prefix="rpc")
 */
class RpcController
{

    /**
     * 在程序初始化的时候定义好服务降级处理类
     * @Reference(pool="message.pool" , fallback="MessageFallback")
     *
     * @var MessageInterface
     */
    private $messageService;



    /**
     * @RequestMapping("returnBool")
     *
     * @return array
     */
    public function returnBool(): array
    {
        $result = $this->userService->delete(12);

        if (is_bool($result)) {
            return ['bool'];
        }

        return ['notBool'];
    }

    /**
     * @RequestMapping()
     *
     * @return array
     */
    public function bigString(): array
    {
        $this->userService->getBigContent();

        return ['string'];
    }

    /**
     * @RequestMapping()
     *
     * @return array
     *
     * @throws Exception
     */
    public function exception(): array
    {
        $this->userService->exception();

        return ['exception'];
    }
}